﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace DynamicDnsChanger.Extensions.DynDNS
{
    class InternalRequester : IRequester
    {
        public event EventHandler<InfoStatus> StatusChange;
        private string username;
        private string password;

        public InternalRequester(string username, string password)
        {
            this.username = username;
            this.password = password;
        }

        public string GetString(string requestUri)
        {
            using (var _request = new WebClient())
            {
                try
                {
                    _request.Credentials = new NetworkCredential(this.username, this.password);
                    _request.Headers.Add("User-Agent", @"DynamicDnsChanger/v1.0 perigo@gmail.com");
                    return _request.DownloadString(new Uri(requestUri));
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }
        }

        public string PostAsync(string requestUri, IDictionary<string, string> content)
        {
            throw new NotImplementedException();
        }

        public string Name
        {
            get { throw new NotImplementedException(); }
        }
    }
}
